﻿using MongoDB.Driver;
using Sustainalytics.ClientDW.Entities;
using System.Collections.Generic;
using System.Linq;

namespace Sustainalytics.ScreeningTool.Synchronization.Handlers
{
    public class GCPrincipleSummaryExtendedHandler : IHandlerWithGrouping<GCPrincipleSummaryExtended>
    {
        public ProjectionDefinition<GCPrincipleSummaryExtended> GetProjection(ProjectionDefinitionBuilder<GCPrincipleSummaryExtended> builder) => builder
            .Include(x => x.Principle.Name);

        public IEnumerable<ExtraElement> GetExtraElements(IEnumerable<GCPrincipleSummaryExtended> entities) => new ExtraElementList
        {
            { "Global Compact Compliance-Principle Breached", entities.Select(x => x.Principle.Name).JoinStrings(";") }
        };
    }
}
